const express = require("express")
const template = require("art-template")
const fs = require("fs")
const app = express()

app.get("/",(rep,res)=>{
    //1.获取页面
    const templateStr = fs.readFileSync("./index.html","utf-8")
    //2.获取数据
    const data = JSON.parse(fs.readFileSync("./data.json","utf-8"))
    //3.渲染： 数据 + 模板 = 结果
    const html = template.render(templateStr,data)
    //4.把渲染结果发送给客户端
    res.send(html)
    console.log(html)
})
app.listen(3000, ()=> console.log('running....'))